#ifndef __MLX90614_H_
#define __MLX90614_H_

#include "stdint.h"
#include <stdio.h>
#include <string.h>
#include <soc.h>

#include "board_config.h"
#include "drv/gpio_pin.h"
#include <drv/pin.h>
#include <aos/aos.h>
#include "aos/cli.h"
#include "delay.h"

csi_gpio_pin_t pin_SCL;
csi_gpio_pin_t pin_SDA;

#define IIC_SCL PA21
#define IIC_SDA PA22

#define SDA_IN()  { csi_gpio_pin_dir(&pin_SDA, GPIO_DIRECTION_INPUT);}
#define SDA_OUT() { csi_gpio_pin_dir(&pin_SDA, GPIO_DIRECTION_OUTPUT);}

//IO操作函数	 
#define  IIC_SCL1 {csi_gpio_pin_write(&pin_SCL, GPIO_PIN_HIGH);}
#define  IIC_SCL0 {csi_gpio_pin_write(&pin_SCL, GPIO_PIN_LOW);}
   
#define  IIC_SDA1 {csi_gpio_pin_write(&pin_SDA, GPIO_PIN_HIGH);}
#define  IIC_SDA0 {csi_gpio_pin_write(&pin_SDA, GPIO_PIN_LOW);}

#define  READ_SDA   csi_gpio_pin_read(&pin_SDA)						//读取SDA的值



//IIC所有操作函数
void IIC_Init(void);                //初始化IIC的IO口				 
void IIC_Start(void);				//发送IIC开始信号
void IIC_Stop(void);	  			//发送IIC停止信号
void IIC_Send_Byte(uint8_t txd);			//IIC发送一个字节
uint8_t IIC_Read_Byte(unsigned char ack);//IIC读取一个字节
uint8_t IIC_Wait_Ack(void); 				//IIC等待ACK信号
void IIC_Ack(void);					//IIC发送ACK信号
void IIC_NAck(void);				//IIC不发送ACK信号 
uint8_t IIC_Write_1Byte(uint8_t SlaveAddress, uint8_t REG_Address,uint8_t REG_data); 		  //完整写一个字节数据
uint8_t IIC_Read_1Byte(uint8_t SlaveAddress, uint8_t REG_Address,uint8_t *REG_data);		  //完整读一个字节数据
uint8_t IIC_Write_nByte(uint8_t SlaveAddress, uint8_t REG_Address,uint16_t len, uint8_t *buf);//IIC写n字节数据
uint8_t IIC_Read_nByte(uint8_t SlaveAddress, uint8_t REG_Address,uint16_t len,uint8_t *buf);  //IIC读n字节数据
float Get_Tem_DATA( uint8_t ReaAd);	//得到测得的温度值

#endif



